home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / mrhp005.arc / MRIM-HP.005
Text File  |  1987-03-06  |  39KB  |  1,081 lines

  1.  
  2.  
  3.    Volume 2, Number 2                                       February 1987
  4.    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5.    ::                  ***************                                 ::
  6.    ::               *********************                              ::
  7.    ::            ***************************                           ::
  8.    ::          ******************************                          ::
  9.    ::        ****************    ************                          ::
  10.    ::      ***************       *************                         ::
  11.    ::     ***************       **************                         ::
  12.    ::    ***************      ***************                          ::
  13.    ::   ****************   *****************                           ::
  14.    ::  *****************   *************                               ::
  15.    ::  *****************   **************          Microrim ONLINE     ::
  16.    :: ******************   ***************         """""""""""""""     ::
  17.    :: ******************   ****************     Online Technical News  ::
  18.    :: ******************   *****************                           ::
  19.    :: ******************   ******************                          ::
  20.    :: ******************   *******************                         ::
  21.    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  22.    Technical tips, techniques, and announcements from Microrim, Inc.
  23.  
  24.    Microrim ONLINE is published electronically approximately every month
  25.    by Microrim, Inc. and distributed exclusively on the Microrim Bulletin
  26.    Board System (BBS).  You can obtain your copy free of charge by
  27.    downloading it from the TECH-ED area of the FILES section.  (206) 881-
  28.    8119.  Setup:  8 data bits, 1 stop bit, No parity, and 300 or 1200
  29.    baud; operating 24 hours, seven days a week.
  30.  
  31.    COPYRIGHT
  32.    """""""""
  33.    Copyright (c) 1987 by Microrim, Inc.  All rights reserved.  Microrim,
  34.    Inc. authorizes the free distribution of this document for educational
  35.    purposes as long as no charge is made and this document is distributed
  36.    exactly as is without modification.  Toward this end, this document
  37.    may be stored in, uploaded to, and downloaded from any Bulletin Board
  38.    Service (BBS) or electronic information service as long as no charge
  39.    is made.
  40.  
  41.    CONTRIBUTIONS
  42.    """""""""""""
  43.    You are encouraged to contribute to MICRORIM ONLINE.  Please upload
  44.    your article, application, or application story to the Microrim BBS or
  45.    send an IBM compatible disk in standard ASCII format to:
  46.  
  47.    Kay D. Dayss, Microrim ONLINE Editor
  48.    Microrim, Inc.
  49.    3925 159th Ave. N.E.
  50.    P.O. Box 97022
  51.    Redmond, WA  98073-9722
  52.  
  53.    By submitting an article or application to MICRORIM ONLINE, you agree
  54.    that the material is not confidential and that Microrim, Inc., may
  55.    use, duplicate, modify, publish, or sell it without obligation or
  56.    liability to you or anyone else.
  57.  
  58.  
  59.    MICRORIM ONLINE February 1987 ------------------------------- Page 1
  60.  
  61.  
  62.    TRADEMARKS
  63.    """"""""""
  64.    R:BASE and Microrim are registered trademarks of Microrim, Inc.
  65.    XRW is a trademark of Microrim, Inc.
  66.    IBM is a registered trademark of International Business Machines Corp.
  67.    XT and AT are trademarks of International Business Machines Corp.
  68.  
  69.    DISCLAIMER
  70.    """"""""""
  71.    Microrim, Inc., makes no representation or warranties with respect to
  72.    the contents hereof, and specifically disclaims any implied warranties
  73.    of merchantability or fitness for any particular purpose.  Further,
  74.    Microrim, Inc., reserves the right to revise this publication and to
  75.    make changes in the content hereof without obligation to notify any
  76.    person of such revision or change and shall not be liable for errors
  77.    contained herein or for incidental or consequential damages in
  78.    connection with the furnishing, performance, or use of this material.
  79.    All opinions and product reviews in MICRORIM ONLINE are those of the
  80.    author and not necessarily those of Microrim, Inc.
  81.  
  82.    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  83.    ::                       TABLE OF CONTENTS                          ::
  84.    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  85.  
  86.    Revision to 3labels Program ........................................ 1
  87.    Conditional Printing in Reports - Negative Balances in Parentheses . 5
  88.    Controlling your Printer ........................................... 8
  89.    Converting Integer Dates to R:BASE Dates ...........................13
  90.    Right-justifying Dollars on Forms ..................................14
  91.    Rounding Reals and Doubles .........................................15
  92.    Elapsed Time .......................................................16
  93.    Subtracting Dates to Get Years and Months ..........................17
  94.    Changing Alt 255s to Alt 32s .......................................18
  95.  
  96.    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.    MICRORIM ONLINE February 1987 ------------------------------- Page 2
  120.  
  121.    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  122.    ::                       TECHNICAL NOTES                            ::
  123.    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  124.  
  125.  
  126.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  127.    REVISION TO 3LABELS PROGRAM
  128.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  129.    DATE      :  1/87                    NUMBER       :  87-1-1
  130.    PRODUCT   :  R:BASE SYSTEM V         VERSIONS     :  ALL
  131.    CATEGORY  :  LABELS                  SUBCATEGORY  :  3LABEL program
  132.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  133.  
  134.    QUESTION:
  135.    """"""""
  136.    How can I get the 3LABELS program provided with R:BASE System V to use
  137.    SORTED BY and WHERE clauses correctly?
  138.  
  139.  
  140.  
  141.    SOLUTION:
  142.    """"""""
  143.    You need to revise the 120th and 123rd lines in the 3LABELS.ASC file
  144.    and then make a new 3LABELS.PRO using CodeLock.  Some of the
  145.    surrounding code is included below to help you locate the two lines.
  146.  
  147.    $COMMAND
  148.    3LABELS
  149.    SET MESSAGE OFF
  150.            o
  151.            o
  152.            o
  153.        WHILE level2 EQ 0  THEN
  154.            o
  155.            o
  156.            o
  157.          IF pick2 EQ 2 THEN
  158.            IF sort EXISTS THEN
  159.    120th-->   SET VAR sortby TO SORTED BY .sort
  160.            ENDIF
  161.            IF cond EXISTS THEN
  162.    123rd-->   SET VAR wclause TO WHERE .cond
  163.            ENDIF
  164.            RUN Prntlab IN 3LABELS.PRO
  165.            IF type EQ Screen THEN
  166.               BEEP
  167.               WRITE " "
  168.               WRITE "Press any key to continue"
  169.               PAUSE
  170.            ENDIF
  171.            BREAK
  172.          ENDIF
  173.        ENDWHILE
  174.            o
  175.            o
  176.            o
  177.  
  178.  
  179.    MICRORIM ONLINE February 1987 ------------------------------- Page 3
  180.  
  181.  
  182.    Change line 120 to:
  183.  
  184.    SET VAR sortby TO ("SORTED BY" & .sort)
  185.  
  186.    Change line 123 to:
  187.  
  188.    SET VAR wclause TO ("WHERE" & .cond)
  189.  
  190.    These changes remove the ambiguity.  The parentheses tell R:BASE
  191.    System V that the variables are being set to expressions, and the
  192.    quotations make it clear that what is inside the quotations should be
  193.    considered one literal string.
  194.  
  195.    After making the changes to 3LABELS.ASC, use option five of CodeLock
  196.    to make a new 3LABELS.PRO program.
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.    MICRORIM ONLINE February 1987 ------------------------------- Page 4
  240.  
  241.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  242.    CONDITIONAL PRINTING IN REPORTS - NEGATIVE BALANCES IN PARENTHESES
  243.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  244.    DATE      :  1/87                    NUMBER       :  87-1-2
  245.    PRODUCT   :  R:BASE SYSTEM V         VERSIONS     :  ALL
  246.    CATEGORY  :  REPORTS                 SUBCATEGORY  :  CONDITIONAL PRINTING
  247.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  248.  
  249.    NEED:
  250.    """"
  251.    I want to print conditionally in my reports.  For example, when I am
  252.    printing dollar totals on a report and the balance is negative I want
  253.    to print it enclosed in parentheses, but when it is positive I do not
  254.    want the parentheses.  I also want to print a list of names and
  255.    underline only the people who are under 21.
  256.  
  257.  
  258.  
  259.    SOLUTION:
  260.    """"""""
  261.    Here are two approaches to conditional processing in reports.  First,
  262.    you can use R:BASE System V SuperMath functions in the report
  263.    expressions in R:BASE System V reports.  An example of this first
  264.    approach is given in the Conditional Parentheses section below.  The
  265.    second approach involves a flag column in the table itself and is
  266.    described in the Conditional Underlining section.
  267.  
  268.    Conditional Parentheses
  269.  
  270.    In this first example, the following functions do the job:
  271.  
  272.      o  The IFLT (if less than) function is used to check and see if the
  273.         balance is less than zero.  If it is, then multiply by -1 and
  274.         enclose it in parentheses.
  275.      o  The CHAR (character) function changes an ASCII integer code to
  276.         the character the code represents.  This function is used to
  277.         convert the ASCII codes of 40 and 41 to the left and right
  278.         parentheses characters.  It is necessary to use the codes for the
  279.         parentheses characters rather than the characters themselves
  280.         because the IFLT function does not permit a text argument.
  281.      o  The CTXT (convert to text) function converts the currency balance
  282.         value to text so that it is possible to concatenate the left
  283.         parenthesis onto the front of it.
  284.      o  The RJS (right justify string) function is needed to right
  285.         justify the dollar amount that has been converted to TEXT so that
  286.         the decimal points align.
  287.  
  288.    In this example report, use the eight variable expressions listed on the
  289.    next page to print customer balances.  The report breaks on CUSTNUM, and
  290.    for each customer number, adds up all the dollar amounts stored in an
  291.    AMOUNT column and puts the result into a CURRENCY variable named VBAL.
  292.    There are three fields located on this report in the break footer:
  293.    CUSTNUM the column holding the customer number, VBALPRNT the TEXT
  294.    variable holding the balance value to be printed (along with the left
  295.    parenthesis if the balance is negative), and  VRIGHT which is blank if
  296.    the balance is positive and is the right parenthesis if the balance is
  297.    negative.  These three variables are shown on the following page.
  298.  
  299.    MICRORIM ONLINE February 1987 ------------------------------- Page 5
  300.  
  301.  
  302.  
  303.          CUSTNUM - column    VBALPRNT - variable    VRIGHT - with the
  304.          |                   |                      |  E on top of the S
  305.    F1    S        E  S                             EE
  306.  
  307.    All eight of the variables are cleared at break time.  The expression
  308.    list looks like this:
  309.  
  310.      1: CURRENCY:  VBAL     =  (.VBAL + 'AMOUNT')
  311.      2: INTEGER :  VLEFTNUM =  (IFLT(.VBAL,0,40,32))
  312.      3: INTEGER :  VRITENUM =  (IFLT(.VBAL,0,41,32))
  313.      4: CURRENCY:  VBALPOS  =  (IFLT(.VBAL,0,(-1*.VBAL),.VBAL))
  314.      5: TEXT    :  VLEFT    =  (CHAR(.VLEFTNUM))
  315.      6: TEXT    :  VRIGHT   =  (CHAR(.VRITENUM))
  316.      7: TEXT    :  VBALTEXT =  (.VLEFT & (CTXT(.VBALPOS)))
  317.      8: TEXT    :  VBALPRNT =  (RJS(.VBALTEXT,30))
  318.  
  319.    The first expression VBAL accumulates the balance.  The second and
  320.    third variables VLEFTNUM and VRITENUM are assigned 40 (the ASCII code
  321.    for the left parenthesis) and 41 (the ASCII code for the right
  322.    parenthesis) if the balance is negative.  If the balance is positive
  323.    then both VLEFTNUM and VRITENUM are assigned ASCII 32 (the code for a
  324.    blank).  The fourth expression VBALPOS strips the negative sign if the
  325.    balance is less than zero.  The fifth and sixth expressions VLEFT and
  326.    VRIGHT convert the ASCII codes stored in VLEFTNUM and VRITENUM to the
  327.    appropriate characters.  The fifth expression VBALTEXT converts the
  328.    balance to TEXT.  The sixth VBALPRNT right justifies it.
  329.  
  330.    Prior to running the report, issue the following three commands to set
  331.    up the environment:
  332.  
  333.    CLEAR vbal vleftnum vritenum vbalpos vleft vright vbaltext vbalprnt
  334.    SET ZERO OFF
  335.    SET NULL " "
  336.  
  337.    Conditional Underlining
  338.  
  339.    To conditionally underline certain items, you can insert printer
  340.    control codes directly into your database into a special column set up
  341.    to hold temporary values.  FLAG is a good name to use for this column.
  342.    Make it a TEXT column.  Now you can use the CHANGE command and the
  343.    CHAR function to insert the appropriate printer control codes into the
  344.    FLAG column for that row of data.
  345.  
  346.    To set up the appropriate CHANGE commands, determine the decimal ASCII
  347.    codes that need to be sent to your printer to set underlining on and
  348.    off.  For example, on an EPSON FX-85, ESC "-1" turns underline on and
  349.    ESC "-0" turns underline off.  These translate to the decimal codes 27
  350.    45 49 to turn underline on and 27 45 48 to turn it off.  To print a
  351.    list of names stored in a NAME column and underline those under 21
  352.    years old (as determined by an AGE column), use the following commands:
  353.  
  354.    CHANGE flag TO (CHAR(27)+CHAR(45)+CHAR(49)) IN tblname WHERE age LT 21
  355.    CHANGE flag TO (CHAR(27)+CHAR(45)+CHAR(48)) IN tblname WHERE age GE 21
  356.  
  357.  
  358.  
  359.    MICRORIM ONLINE February 1987 ------------------------------- Page 6
  360.  
  361.  
  362.    When you define the report, locate the FLAG column immediately before
  363.    the column you want to selectively underline.  For this example, there
  364.    are two only fields located on the report:
  365.  
  366.        FLAG - column    NAME - column
  367.        |                |
  368.    S       ES                                   E
  369.  
  370.    Now, when you print the report, the FLAG column will control whether
  371.    the NAME is underlined or not.  This is because the FLAG column
  372.    contains either the printer control codes that turn underline on or
  373.    the codes that turn underline off.
  374.  
  375.    For further information on printer control codes, see Microrim
  376.    Technical Note number 87-1-3,  Controlling Your Printer.
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.    MICRORIM ONLINE February 1987 ------------------------------- Page 7
  420.  
  421.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  422.    CONTROLLING YOUR PRINTER
  423.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  424.    DATE      :  1/87                    NUMBER       :  87-1-3
  425.    PRODUCT   :  R:BASE SYSTEM V         VERSIONS     :  ALL
  426.                 R:BASE 5000                             ALL
  427.    CATEGORY  :  PRINTING                SUBCATEGORY  :  PRINTER CONTROL CODES
  428.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  429.  
  430.    NEED:
  431.    """"
  432.    I need to send printer control codes to my printer from reports,
  433.    command files, and from the R> prompt.
  434.  
  435.  
  436.  
  437.    SOLUTION:
  438.    """"""""
  439.    You can use your printer's special control characters within R:BASE.
  440.    Each printer is different.  Your printer manual explains what codes
  441.    are applicable for your printer.  Your R:BASE manual explains how to
  442.    send printer control codes to your printer in an R:BASE 5000 or R:BASE
  443.    System V report.
  444.  
  445.    It is also possible to control your printer by using global variables
  446.    at the R> prompt (in R:BASE System V), in your reports, or in command
  447.    files.  In this way you can:
  448.  
  449.      o  Change the appearance of reports by changing fonts for different
  450.         sections.
  451.      o  Use different printers with the same application when one printer
  452.         uses one set of control codes and another uses a different set.
  453.      o  Enter printer control codes directly at an R> prompt.  This is
  454.         useful, for example, when you want to print a list with the
  455.         SELECT command and you want to skip over the perforations in the
  456.         printer's paper.
  457.  
  458.    R:BASE 5000 Method
  459.  
  460.    Using this method, you can pass printer control codes to your reports
  461.    through global variables.  Below is a way to do this using menus that
  462.    allow the user to pick the print style wanted for each section of the
  463.    report.
  464.  
  465.    Essentially, you are changing the REPORTS table, but it is being done
  466.    in a way that is transparent to the user.  The main command file is
  467.    PRINTER.2.  It calls another command file named CHANGE.2.  The two
  468.    command files are listed below.
  469.  
  470.    If you have R:BASE System V, you do not need to change the REPORTS
  471.    table, but you might like to adopt the "menus" approach used here.  In
  472.    this example for R:BASE 5000, the user is presented with three menus
  473.    in succession.  From the first menu, the user picks the print style
  474.    for the page heading.  Next, the user sees a menu asking for the style
  475.    for the break heading.  Finally, there is another menu for the detail.
  476.    These examples can be changed to suit your particular report.
  477.  
  478.  
  479.    MICRORIM ONLINE February 1987 ------------------------------- Page 8
  480.  
  481.    Here are the menus:
  482.  
  483.    *( PGHEAD.MNU )
  484.    +----------------------CHOOSE MODE FOR PAGE HEADING---------------------+
  485.    |  Normal Print   Compressed Print    Italics        Emphasized Print   |
  486.    |  Double-strike  Underlined          Enlarged Print                    |
  487.    +-----------------------------------------------------------------------+
  488.  
  489.    *( BRKHEAD.MNU )
  490.    +--------------------CHOOSE MODE FOR BREAK HEADING----------------------+
  491.    |  Normal Print   Compressed Print    Italics        Emphasized Print   |
  492.    |  Double-strike  Underlined          Enlarged Print                    |
  493.    +-----------------------------------------------------------------------+
  494.  
  495.    *( DETAIL.MNU )
  496.    +-----------------CHOOSE MODE FOR DETAIL INFORMATION--------------------+
  497.    |  Normal Print   Compressed Print    Italics        Emphasized Print   |
  498.    |  Double-strike  Underlined          Enlarged Print                    |
  499.    +-----------------------------------------------------------------------+
  500.  
  501.    Here are the program listings for the two command files PRINTER.2 and
  502.    CHANGE.2:
  503.  
  504.    *( PRINTER.2 )
  505.    OPEN control
  506.    CLEAR ALL VAR
  507.    SET MESSAGE OFF
  508.    SET ERROR MESSAGE OFF
  509.  
  510.    *(INITIALIZE VARIABLES TO NAMES OF REP VARS AS THEY APPEAR IN RDATA)
  511.    SET VAR vhpon TO " HEADING (TEXT) ="
  512.    SET VAR vhpoff TO " HEADING2 (TEXT) ="
  513.    SET VAR vh1on TO " BRKHEAD (TEXT) ="
  514.    SET VAR vh1off TO " BRKHEAD2 (TEXT) ="
  515.    SET VAR vdon TO " DATALINE (TEXT) ="
  516.    SET VAR vdoff TO " DATALIN2 (TEXT) ="
  517.    SET VAR vpart3 TO " (VALUE, TEXT)"
  518.    SET VAR vloop TO Y
  519.  
  520.    WHILE vloop = Y THEN
  521.      NEW
  522.      CHOOSE vhppick FROM PGHEAD.MNU
  523.      IF vhppick = ESC THEN
  524.        WRITE "No Choice Made"
  525.        GOTO BOTTOM
  526.      ENDIF
  527.      IF vhppick = HELP THEN
  528.        WRITE "Display a Help Screen Here"
  529.          *( DISPLAY the help.scr file. )
  530.        QUIT TO PRINTER.2
  531.      ENDIF
  532.  
  533.      CHOOSE vh1pick FROM brkhead.mnu
  534.      CHOOSE vdpick FROM detail.mnu
  535.  
  536.  
  537.  
  538.  
  539.    MICRORIM ONLINE February 1987 ------------------------------- Page 9
  540.  
  541.    *( Now, the user's choices are used to lookup the correct control
  542.       code and recreate a row in the REPORTS table's RDATA column to
  543.       replace the one which previously contained the printer control code)
  544.      RUN CHANGE.2 USING .vhppick .vhpon .vhpoff
  545.      RUN CHANGE.2 USING .vh1pick .vh1on .vh1off
  546.      RUN CHANGE.2 USING .vdpick .vdon .vdoff
  547.  
  548.      OUTPUT PRINTER
  549.      PRINT calls
  550.      OUTPUT SCREEN
  551.    ENDWHILE
  552.    LABEL BOTTOM
  553.  
  554.  
  555.    *( CHANGE.2 )
  556.    SET VAR vcodeon TO STRING IN prnctrl WHERE desc = .%1
  557.    SET VAR vcodeoff TO CANCEL IN prnctrl WHERE desc = .%1
  558.    SET VAR vnewrpt1 TO .%2 & .vcodeon
  559.    SET VAR vnewrpt1 TO .vnewrpt1 & .vpart3
  560.    SET VAR vnewrpt2 TO .%3 & .vcodeoff
  561.    SET VAR vnewrpt2 TO .vnewrpt2 & .vpart3
  562.    CHANGE RDATA TO .vnewrpt1 IN REPORTS WHERE RDATA CON .%2 AND RNAME = calls
  563.    CHANGE RDATA TO .vnewrpt2 IN REPORTS WHERE RDATA CON .%3 AND RNAME = calls
  564.  
  565.    Based on the user's choice, the CHANGE.2 command file looks up the
  566.    appropriate codes in a table named PRNCTRL.  The table PRNCTRL has
  567.    been loaded previously with the appropriate control codes for turning
  568.    that style on and off.  Example contents of the table are listed
  569.    below:
  570.  
  571.    STRING    DESC             CANCEL
  572.    --------- ---------------- ---------
  573.    <27 87 1> ENLARGED PRINT   <27 87 0>
  574.    <15>      COMPRESSED PRINT <18>
  575.    <27 52>   ITALICS          <27 53>
  576.    <27 69>   EMPHASIZED PRINT <27 70>
  577.    <27 71>   DOUBLE-STRIKE    <27 72>
  578.    <27 45 1> UNDERLINED       <27 45 0>
  579.    <18>      NORMAL PRINT     <18>
  580.  
  581.    Next, the CHANGE.2 command file concatenates the appropriate
  582.    information together to form a new row for the REPORTS table which
  583.    will replace the old definition of that variable.
  584.  
  585.    For example, if the name of the report variable is HEADING, then the
  586.    data in the RDATA column in REPORTS looks like this:
  587.  
  588.     HEADING (TEXT) = <15> (VALUE,TEXT)
  589.  
  590.    The CHANGE.2 command file concatenates the VHPON variable (containing
  591.    HEADING (TEXT) = ) with the variable containing the appropriate
  592.    printer control code (for example, <27 72>) forming a temporary
  593.    variable.  The temporary variable is then concatenated to the VPART3
  594.    variable, which contains the last portion of the report variable
  595.  
  596.  
  597.  
  598.  
  599.    MICRORIM ONLINE February 1987 ------------------------------- Page 10
  600.  
  601.    definition, (VALUE, TEXT), forming VNEWRPT1 which now contains the
  602.    following:    HEADING (TEXT) = <27 72> (VALUE, TEXT)
  603.  
  604.    The command file then executes a CHANGE command to replace the data in
  605.    the RDATA column with the value of this new variable.
  606.  
  607.    Look near the top of the PRINTER.2 listing and you will find that in
  608.    the INITIALIZE VARIABLES section each of the variables VHPON through
  609.    VPART3 are initialized with leading blanks.  These leading blanks are
  610.    important because that is how the report variables are stored, so be
  611.    sure to include them.
  612.  
  613.    When creating the menus using RBEDIT, make sure there is a line before
  614.    the one that starts with the word ROW.  This is a requirement for menu
  615.    files. It can be a blank line, or it can contain the name of the menu
  616.    if you plan to compile it into a procedure file.  You have the option
  617.    of displaying a help screen if the user presses [F10] instead of
  618.    making a menu pick.
  619.  
  620.    Use the following files to create the menus shown on pages one and
  621.    two:
  622.  
  623.    *( PGHEAD.MNU )
  624.    ROW CHOOSE MODE FOR PAGE HEADING
  625.    Normal Print
  626.    Compressed Print
  627.    Italics
  628.    Emphasized Print
  629.    Double-strike
  630.    Underlined
  631.    Enlarged Print
  632.  
  633.  
  634.    *( BRKHEAD.MNU )
  635.    ROW CHOOSE MODE FOR BREAK HEADING
  636.    Normal Print
  637.    Compressed Print
  638.    Italics
  639.    Emphasized Print
  640.    Double-strike
  641.    Underlined
  642.    Enlarged Print
  643.  
  644.  
  645.    *( DETAIL.MNU )
  646.    ROW CHOOSE MODE FOR DETAIL INFORMATION
  647.    Normal Print
  648.    Compressed Print
  649.    Italics
  650.    Emphasized Print
  651.    Double-strike
  652.    Underlined
  653.    Enlarged Print
  654.  
  655.  
  656.  
  657.  
  658.  
  659.    MICRORIM ONLINE February 1987 ------------------------------- Page 11
  660.  
  661.    R:BASE System V Method
  662.  
  663.    R:BASE System V allows more flexibility because of the CHAR function
  664.    and because global variables can be used directly in your report.
  665.    Therefore, there is no need to modify the REPORTS table.  You can set
  666.    variables directly to printer control codes and then control the
  667.    printer from the R> prompt or use the variable in a report and control
  668.    the appearance of the report.
  669.  
  670.    For example, if the printer control code for turning on skip-over-
  671.    perforation is ESC 78 and the code for turning it off is ESC 79, you
  672.    can use the following short command file to turn it on, print a list
  673.    with the SELECT command and then turn it back off:
  674.  
  675.    SET LINES 0
  676.    SET VAR vperfon TEXT
  677.    SET VAR vperfoff TEXT
  678.    SET VAR vperfon TO (CHAR(27)+CHAR(78))
  679.    SET VAR vperfoff TO (CHAR(27)+CHAR(79))
  680.    OUTPUT PRINTER
  681.    SHOW VAR vperfon
  682.    SELECT name FROM list
  683.    SHOW VAR vperfoff
  684.    OUTPUT SCREEN
  685.  
  686.    If you like, you can also set up a series of menus from which the user
  687.    can pick which print styles to use.  With R:BASE System V you can load
  688.    these menu choices directly into global variables such as VRPTHEAD
  689.    (for the report header print style), VBRKHEAD (for the break header
  690.    font), and VDETAIL (to control how the detail will look) and then use
  691.    these global variables directly from the R> prompt (with the SHOW VAR
  692.    command), inside a command file, or in your report.  Sample menus are
  693.    shown in the R:BASE 5000 Method section above.
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.    MICRORIM ONLINE February 1987 ------------------------------- Page 12
  720.  
  721.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  722.    CONVERTING INTEGER DATES TO R:BASE DATES
  723.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  724.    DATE      :  1/87                    NUMBER       :  87-1-4
  725.    PRODUCT   :  R:BASE SYSTEM V         VERSIONS     :  ALL
  726.    CATEGORY  :  CONVERSION              SUBCATEGORY  :  INTEGER TO DATE
  727.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  728.  
  729.    NEED:
  730.    """"
  731.    When I import data from a file into R:BASE, I have trouble with the
  732.    date columns.  In the file, the dates are listed without delimiters as
  733.    six digit numbers.  For example, October 1, 1986, is listed as:
  734.  
  735.    100186
  736.  
  737.    When these fields are loaded, R:BASE interprets them as INTEGER data
  738.    types.  How can I convert them to the R:BASE DATE data type?
  739.  
  740.  
  741.  
  742.    SOLUTION:
  743.    """"""""
  744.    Use the commands listed below to define two columns for this field in
  745.    your R:BASE table.  Define one column ICOLNAME as an INTEGER column
  746.    and load the value from the file into this column.  Define the second
  747.    column DCOLNAME as a computed DATE column.  When you enter the
  748.    DCOLNAME expression, do not enter the plus sign (+) shown at the end
  749.    of each of the first two lines.  These are continuation characters and
  750.    are automatically inserted by R:BASE System V as needed.
  751.  
  752.    DEFINE dbname
  753.    COLUMN
  754.    icolname INTEGER
  755.    dcolname =(RDATE((INT('icolname'/10000)),((INT('icolname'/100))+
  756.    -((INT('icolname'/10000))*100)),('icolname'-((INT('icolname'/100))+
  757.    *100)))) DATE
  758.  
  759.    For example, if a file named DATEFILE.DAT contains the integers 10186,
  760.    101087, and 123085, and if you load them into a table named DATETBL
  761.    with the LOAD command (LOAD datetbl FROM datefile.dat USING icolname),
  762.    the table will hold these rows:
  763.  
  764.     icolname  dcolname
  765.     --------  --------
  766.        10186  01/01/86
  767.       101087  10/10/87
  768.       123085  12/30/85
  769.  
  770.    The computed column automatically determines the correct date and
  771.    format based on the INTEGER value in the INTEGER column.
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.    MICRORIM ONLINE February 1987 ------------------------------- Page 13
  780.  
  781.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  782.    RIGHT-JUSTIFYING DOLLARS ON FORMS
  783.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  784.    DATE      :  1/87                    NUMBER       :  87-1-5
  785.    PRODUCT   :  R:BASE SYSTEM V         VERSIONS     :  ALL
  786.    CATEGORY  :  FORMS                   SUBCATEGORY  :  DOLLAR FORMATS
  787.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  788.  
  789.    NEED:
  790.    """"
  791.    When entering data in a CURRENCY field in an R:BASE System V form,
  792.    R:BASE System V automatically left-justifies CURRENCY columns so that
  793.    it is easy for the operator to enter the data.  However, when I am
  794.    only displaying dollars on a form, I want to right-justify them so
  795.    that the decimal points align.
  796.  
  797.  
  798.  
  799.    SOLUTION:
  800.    """"""""
  801.    David McCann of Classic Micro Systems, North Hollywood, CA provides
  802.    this solution.
  803.  
  804.    Although you cannot enter values on a form and then align them within
  805.    the same input field, you can align values which have been computed,
  806.    displayed in a separate location on the form, or looked-up from
  807.    another table and then displayed.  Here is an example.
  808.  
  809.    First, start with any existing form on which you would like to display
  810.    right-justified CURRENCY fields.
  811.  
  812.    Second, define an expression for each value you wish to locate on your
  813.    form using the R:BASE System V conversion function CTXT to convert a
  814.    CURRENCY amount to TEXT.  For example, to convert the column AMOUNT to
  815.    TEXT, define this expression:  vtxtamt = (CTXT('amount'))
  816.  
  817.    Third, define another expression using the string function RJS to
  818.    right-justify that text within a given field.  For example, to right-
  819.    justify the TEXT value defined previously in an eight-character field,
  820.    define this expression:  vramount = (RJS(.vtxtamt,8))
  821.  
  822.    Fourth, locate the right-justified variable VRAMOUNT on your form.
  823.    Make this field display only by modifying the field characteristics to
  824.    tell R:BASE that no new data will be entered in the field and that the
  825.    data displayed in the field is not editable.
  826.  
  827.    Now you can display a column of CURRENCY values which all align on the
  828.    decimal point.  If you have ZERO set on, NULL CURRENCY values display
  829.    as $0.00.  With ZERO set off, NULL CURRENCY values appear as blanks.
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.    MICRORIM ONLINE February 1987 ------------------------------- Page 14
  840.  
  841.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  842.    ROUNDING REALS AND DOUBLES
  843.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  844.    DATE      :  1/87                    NUMBER       :  87-1-6
  845.    PRODUCT   :  R:BASE SYSTEM V         VERSIONS     :  ALL
  846.    CATEGORY  :  MATH                    SUBCATEGORY  :  ROUNDING
  847.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  848.  
  849.    QUESTION:
  850.    """"""""
  851.    How can I round a REAL or DOUBLE number to two decimal places?
  852.  
  853.  
  854.  
  855.    SOLUTION:
  856.    """"""""
  857.    Use the ANINT function.
  858.  
  859.    First, multiply the REAL or DOUBLE number by a multiplier constant
  860.    (100 for example) after adding the applicable rounding constant (.005
  861.    for this example).  Next, take the ANINT of the result.  Finally,
  862.    divide the new result by the same multiplier constant.  If you use the
  863.    multiplier constant 100, you end up with a real number rounded to two
  864.    decimal places.
  865.  
  866.    For example, the following code will round the number 28.376 to two
  867.    decimal places.
  868.  
  869.    SET VAR vround REAL
  870.    SET VAR vround TO 28.376
  871.    SET VAR vround TO ((ANINT((.vround+.005)*100))/100)
  872.  
  873.    In this example, .005 is the rounding constant and 100 is the
  874.    multiplier constant.  After running these three commands, VROUND
  875.    equals 28.38.
  876.  
  877.    The number of decimal places you want determines the multiplier and
  878.    rounding constants in the expression.  For one decimal place, add .05,
  879.    multiply by 10, and then divide by 10.  For two decimal places, add
  880.    .005, multiply by 100, and then divide by 100.  For three decimal
  881.    places, add .0005, multiply by 1000, and then divide by 1000, and so
  882.    on.
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.    MICRORIM ONLINE February 1987 ------------------------------- Page 15
  900.  
  901.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  902.    ELAPSED TIME
  903.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  904.    DATE      :  1/87                    NUMBER       :  87-1-7
  905.    PRODUCT   :  R:BASE SYSTEM V         VERSIONS     :  ALL
  906.    CATEGORY  :  MATH                    SUBCATEGORY  :  TIME MATH AND MIDNIGHT
  907.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  908.  
  909.    NEED:
  910.    """"
  911.    Subtracting times that start after midnight from times that start
  912.    before midnight results in a negative number.  R:BASE System V assumes
  913.    that the start time is later that day instead of the day before.  For
  914.    example, if the start time is 23:00, the stop time is 01:00, and the
  915.    expression ((STOP-START)/60) defines elapsed minutes, R:BASE System V
  916.    tells me that the elapsed minutes are -1320 when the answer I am
  917.    seeking is 120 minutes.
  918.  
  919.  
  920.  
  921.    SOLUTION:
  922.    """"""""
  923.    Steven P. Vellella of BV Custom Software, Corapolis, PA, provides the
  924.    following solution.
  925.  
  926.    Use the IFLT function.  For example, if you want to put the elapsed
  927.    time in a computed column named ELAPSE, and the start and stop times
  928.    are in the columns START and STOP, use the commands listed below to
  929.    define the three columns.  Do not enter the plus sign (+) shown at the
  930.    end of the first line in the ELAPSE expression.  It is a continuation
  931.    character automatically inserted by R:BASE System V.
  932.  
  933.    DEFINE dbname
  934.    COLUMN
  935.    start TIME
  936.    stop TIME
  937.    elapse =IFLT((('stop'-'start')/60),0,(('stop'-'start')/60+1440),+
  938.      (('stop'-'start')/60)) INTEGER
  939.  
  940.    The IFLT function, used in the computed column ELAPSE, reads in
  941.    English like this:  If STOP minus START divided by 60 is less than
  942.    zero, add 1440 (the number of minutes in a day) to the result.
  943.    Otherwise, simply compute the result (('STOP'-'START')/60) without
  944.    adding the additional minutes.
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.    MICRORIM ONLINE February 1987 ------------------------------- Page 16
  960.  
  961.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  962.    SUBTRACTING DATES TO GET YEARS AND MONTHS
  963.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  964.    DATE      :  1/87                    NUMBER       :  87-1-8
  965.    PRODUCT   :  R:BASE SYSTEM V         VERSIONS     :  ALL
  966.    CATEGORY  :  MATH                    SUBCATEGORY  :  DATE MATH
  967.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  968.  
  969.    NEED:
  970.    """"
  971.    I want to subtract two dates and show the result as the number of
  972.    approximate years and months.
  973.  
  974.  
  975.    SOLUTION:
  976.    """"""""
  977.    You can subtract two dates and show the result as years and months by
  978.    using the two R:BASE System V SuperMath functions INT and MOD.
  979.    Subtract the two dates and divide the result by 365 (the number of
  980.    days in a year) and use the two functions on the result.  The INT
  981.    (integer) function extracts the portion of the result that lies to the
  982.    left of the decimal point.  The MOD (modulus or remainder of one
  983.    argument divided by a second) function pulls off the portion to the
  984.    right of the decimal point.
  985.  
  986.    For example, if you have two DATE columns in your table named STARTDAY
  987.    and STOPDAY, add two computed columns YEARS and MONTHS to hold the
  988.    number of years and remaining months.  Define these two computed
  989.    columns using the expressions listed below.
  990.  
  991.    years =(INT(('stopday'-'startday')/365.)) INTEGER
  992.    months =(INT(MOD(('stopday' - 'startday'),365.)/30.)) INTEGER
  993.  
  994.    The YEARS expression reads in English as follows: subtract STARTDAY
  995.    from STOPDAY and divide the result by 365.  Then take the INTEGER
  996.    result (the part to the left of the decimal point) and store it in the
  997.    YEARS column.
  998.  
  999.    The MONTHS expression reads: subtract STARTDAY from STOPDAY and divide
  1000.    the result by 365.  Take the modulus of that number (the part that
  1001.    lies to the right of the decimal point) as a whole integer number.
  1002.    Now, divide that number by 30 to come up with the number of whole
  1003.    months.
  1004.  
  1005.    This method gives you the approximate number of years and months.  It
  1006.    assumes that all months have 30 days and all years have 365 days.  If
  1007.    you need a more accurate answer, you can do it by creating more
  1008.    complex expressions.  If you want to be exact, you may need to use
  1009.    several different expressions, assign the intermediate results to
  1010.    variables, and then use the CHANGE command to put the final answer
  1011.    into the column.  You could, for example, determine which months are
  1012.    being included and add the correct number of days for each month.  You
  1013.    could even check for leap years and if the entire month of february is
  1014.    included for that year, use 29 days rather than 28.  However, every
  1015.    level of complexity will add execution time.  You need to assess
  1016.    whether the benefit (small increase in accuracy) is worth the cost in
  1017.    terms of execution time.
  1018.  
  1019.    MICRORIM ONLINE February 1987 ------------------------------- Page 17
  1020.  
  1021.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  1022.    CHANGING ALT 255s TO ALT 32s
  1023.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  1024.    DATE      :  1/87                    NUMBER       :  87-1-9
  1025.    PRODUCT   :  R:BASE SYSTEM V         VERSIONS     :  ALL
  1026.    CATEGORY  :  CONVERSION              SUBCATEGORY  :  ALT 255 to 32
  1027.    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  1028.  
  1029.    NEED:
  1030.    """"
  1031.    At various times I like to use an ALT 255 in my R:BASE System V
  1032.    application files, menus, or reports.  The ALT 255 looks like a normal
  1033.    blank (which is an ALT 32) on the screen, but it causes some printers
  1034.    to go haywire because it is interpreted as a control character.  I
  1035.    like to use the ALT 255 to blank out sections in my reports and to
  1036.    make more attractive menu titles.  How can I use ALT 255s but have the
  1037.    printer interpret them as ALT 32s?
  1038.  
  1039.  
  1040.  
  1041.    SOLUTION:
  1042.    """"""""
  1043.    You can change the defaults to have an ALT 255 interpreted as an ALT
  1044.    32 when sent to the printer by revising the PRINTER.ASC file and
  1045.    making a new DEFAULT.MSG file.  See chapter 10 in your R:BASE System V
  1046.    User's Manual for a complete description of the default files.
  1047.  
  1048.    To change ALT 255s to ALT 32s before they reach your printer, revise
  1049.    the PRINTER.ASC file and make sure that it resides with the
  1050.    DEFAULT.MSG file in the same directory as your R:BASE System V program
  1051.    files.
  1052.  
  1053.    After making a backup of the original version of the PRINTER.ASC file,
  1054.    use an editor to insert the following line as a new entry in the
  1055.    table:
  1056.  
  1057.      255    32  0  0
  1058.  
  1059.    Note that the 255 starts in column three and the 32 starts in column
  1060.    nine.  The first zero is in column 13, and the second zero is in
  1061.    column 16.  You can place this new line anywhere in the list.
  1062.  
  1063.    Finally, make sure that DEFGEN.EXE, DEFAULT.ASC, and the new
  1064.    PRINTER.ASC files are all on your default drive and from the DOS
  1065.    prompt, type:
  1066.  
  1067.    DEFGEN DEFAULT.ASC
  1068.  
  1069.    This will generate a new DEFAULT.MSG file with your changes recorded.
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.    MICRORIM ONLINE February 1987 ------------------------------- Page 18
  1080.  
  1081.